home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- * GEMTERM V1.2
- * 1992 by Martin F. Gergeleit
- * placed in the public domain
- *
- * GEMTERM COMES WITH ABSOLUTELY NO WARRANTY, NOR WILL I BE LIABLE FOR ANY
- * DAMAGES INCURRED FROM THE USE OF IT. USE ENTIRELY AT YOUR OWN RISK!!!
- *********************************************************************/
-
- #include <gemfast.h>
- #include <osbind.h>
- #include <mintbind.h>
- #include <filesys.h>
- #include <basepage.h>
- #include "txtwin.h"
-
- #ifdef DEBUG
- #include <stdio.h>
- #endif
-
- extern int gl_hchar;
- extern int gl_wchar;
- extern int gl_wbox;
- extern int gl_hbox; /* system sizes */
-
- extern int xdesk,ydesk,hdesk,wdesk;
- extern int handle;
- extern int tty;
- extern short tty_used;
-
- static int start_pos = 5;
- static char mem_txt[] = "[0][Not enough memory ][Hmm]";
-
- int ret;
-
- init_txt_win(win, font, height)
- txt_win *win;
- int font, height;
-
- {
- int i;
- int tmpx, tmpy, tmpw, tmph;
-
- #ifdef DEBUG
- fprintf(stderr, "init_txt_win starts\n");
- #endif
-
- win->wtext = (char *)malloc(win->lines * (win->cols+1));
- if (win->wtext == 0) {
- form_alert(1, mem_txt);
- return;
- }
- win->attr = (char *)malloc(win->lines * win->cols);
- if (win->attr == 0) {
- free(win->wtext);
- win->wtext = 0;
- form_alert(1, mem_txt);
- return;
- }
- for (i = 0; i < win->lines; i++)
- win->wtext[i * (win->cols+1)] = '\0';
-
- win->font = font;
- win->height = height;
- vst_font(handle, win->font);
- vst_point(handle, win->height, &ret,&ret,&win->c_width,&win->c_height);
- #ifdef DEBUG
- fprintf(stderr, "fonts initialized\n");
- #endif
-
- win->xwork = xdesk;
- win->ywork = ydesk;
- win->wwork = win->cols * win->c_width;
- win->hwork = win->lines * win->c_height;
-
- win->hs_s = 0;
- win->hs_p = 0;
- win->vs_s = 0;
- win->vs_p = 0;
-
- win->x_start = 0;
- win->y_start = win->lines - 1;
- win->x_cursor = 0;
- win->y_cursor = 0;
- win->esc = 0;
- win->wrap_line = TRUE;
- win->reverse_video = FALSE;
- win->cursor_enabled = TRUE;
- win->x_save = 0;
- win->y_save = 0;
-
- win->hist_in = 0;
- win->history = (char *)malloc(win->hist_size);
- win->hist_out = win->hist_size-1;
- win->history[win->hist_out] = '\0';
- win->lines_written = 0;
- win->last_out = win->hist_size + 1;
-
- win->status = UNSHOWN;
- win->fulled = FALSE;
-
- win->pid = NO_PID;
-
- wind_calc(1, WI_KIND, xdesk+start_pos, ydesk+start_pos, wdesk-start_pos,
- hdesk-start_pos, &win->xwork, &win->ywork, &win->wwork,
- &win->hwork);
- start_pos = (start_pos + 10) % 40;
-
- if ((win->cols * win->c_width) < win->wwork)
- win->wwork = win->cols * win->c_width;
- if ((win->lines * win->c_height) < win->hwork)
- win->hwork = win->lines * win->c_height;
- win->hwork = (win->hwork / win->c_height) * win->c_height;
- wind_calc(0, WI_KIND, win->xwork, win->ywork, win->wwork, win->hwork,
- &tmpx, &tmpy, &tmpw, &tmph);
-
- #ifdef DEBUG
- fprintf(stderr, "init_txt_window ends\n");
- #endif
- }
-
- update_txt_win(win)
- txt_win *win;
- {
- int i;
- char c;
- int cursor_hop;
- int linecount = 5;
-
- #ifdef DEBUG
- fprintf(stderr, "update_txt_window starts\n");
- #endif
-
- if (win->status == OPEN) {
- vst_font(handle, win->font);
- vst_point(handle, win->height, &ret,&ret,&ret,&ret);
-
- graf_mouse(M_OFF,0x0L);
- wind_update(TRUE);
- }
-
- cursor(win, FALSE);
-
- while ((Finstat(win->real_pty)) && (linecount > 0)) {
- cursor_hop = FALSE;
- c = (char)Fgetchar(win->real_pty,0);
-
- #ifdef DEBUG
- fprintf(stderr, "got char: %x\n", c);
- #endif
-
- if (win->y_start + 1 < win->hwork/win->c_height) {
- win->y_start = win->lines - 1;
- do_wm_redraw(win);
- update_slider(win);
- }
-
- if (win->esc == 5) {
- /* Background Color */
- win->esc = 0;
- }
- else if (win->esc == 4) {
- /* Foreground Color */
- win->esc = 0;
- }
- else if (win->esc == 2) {
- win->y_cursor = (short)c - ' ';
- if (win->y_cursor >= win->lines)
- win->y_cursor = win->lines-1;
- win->esc = 3;
- }
- else if (win->esc == 3) {
- win->x_cursor = (short)c - ' ';
- if (win->x_cursor >= win->cols)
- win->x_cursor = win->cols-1;
- cursor_hop = TRUE;
- win->esc = 0;
- }
- else if (win->esc == 1) {
- win->esc = 0;
- switch (c) {
- case 'A':
- if (win->y_cursor > 0)
- win->y_cursor--;
- cursor_hop = TRUE;
- break;
- case 'B':
- if (win->y_cursor < win->lines)
- win->y_cursor++;
- cursor_hop = TRUE;
- break;
- case 'C':
- if (win->x_cursor < win->cols)
- win->x_cursor++;
- cursor_hop = TRUE;
- break;
- case 'D':
- if (win->x_cursor > 0)
- win->x_cursor--;
- break;
- case 'E':
- win->x_cursor = 0;
- win->y_cursor = 0;
- for (i = 0; i < win->lines; i++)
- win->wtext[i * (win->cols+1)] = '\0';
- clear_area(win, 0, 0, win->cols-1, win->lines-1);
- break;
- case 'H':
- win->x_cursor = 0;
- win->y_cursor = 0;
- break;
- case 'I':
- if (win->y_cursor != 0)
- win->y_cursor--;
- else {
- for (i = win->lines - 1; i > 0; i--) {
- strcpy(&win->wtext[i*(win->cols+1)], &win->wtext[(i-1)*(win->cols+1)]);
- bcopy(&win->attr[(i-1)*win->cols], &win->attr[i*win->cols], win->cols);
- }
- win->wtext[0] = '\0';
- do_wm_redraw(win);
- }
- cursor_hop = TRUE;
- break;
- case 'J':
- clear_area(win, win->x_cursor, win->y_cursor, win->cols-1, win->y_cursor);
- clear_area(win, 0, win->y_cursor+1, win->cols-1, win->lines-1);
- win->wtext[win->y_cursor* (win->cols+1) + win->x_cursor] = '\0';
- for (i = win->y_cursor + 1; i < win->lines; i++)
- win->wtext[i* (win->cols+1)] = '\0';
- break;
- case 'K':
- clear_area(win, win->x_cursor, win->y_cursor, win->cols-1, win->y_cursor);
- win->wtext[win->y_cursor* (win->cols+1) + win->x_cursor] = '\0';
- break;
- case 'L':
- for (i = win->lines - 1; i > win->y_cursor; i--) {
- strcpy(&win->wtext[i*(win->cols+1)], &win->wtext[(i-1)*(win->cols+1)]);
- bcopy(&win->attr[(i-1)*win->cols], &win->attr[i*win->cols], win->cols);
- }
- win->x_cursor = 0;
- win->wtext[win->y_cursor* (win->cols+1)] = '\0';
- do_wm_redraw(win);
- break;
- case 'M':
- for (i = win->y_cursor + 1; i < win->lines; i++) {
- strcpy(&win->wtext[(i-1)*(win->cols+1)], &win->wtext[i*(win->cols+1)]);
- bcopy(&win->attr[i*win->cols], &win->attr[(i-1)*(win->cols+1)], win->cols);
- }
- win->x_cursor = 0;
- win->wtext[(win->lines-1) * (win->cols+1)] = '\0';
- do_wm_redraw(win);
- break;
- case 'Y':
- win->esc = 2;
- break;
- case 'b':
- win->esc = 4;
- break;
- case 'c':
- win->esc = 5;
- break;
- case 'd':
- clear_area(win, 0, 0, win->cols-1, win->y_cursor-1);
- clear_area(win, 0, win->y_cursor, win->x_cursor, win->y_cursor);
- for (i = 0 ; i <= win->y_cursor; i++)
- win->wtext[win->y_cursor * (win->cols+1)] = '\0';
- for (i = 0 ; i <= win->x_cursor; i++)
- win->wtext[win->y_cursor* (win->cols+1) + i] = ' ';
- break;
- case 'e':
- win->cursor_enabled = TRUE;
- break;
- case 'f':
- win->cursor_enabled = FALSE;
- break;
- case 'j':
- win->x_save = win->x_cursor;
- win->y_save = win->y_cursor;
- break;
- case 'k':
- win->x_cursor = win->x_save;
- win->y_cursor = win->y_save;
- cursor_hop = TRUE;
- break;
- case 'l':
- clear_area(win, 0, win->y_cursor, win->cols-1, win->y_cursor);
- win->x_cursor = 0;
- win->wtext[win->y_cursor* (win->cols+1)] = '\0';
- break;
- case 'o':
- clear_area(win, 0, win->y_cursor, win->x_cursor, win->y_cursor);
- for (i = 0 ; i <= win->x_cursor; i++)
- win->wtext[win->y_cursor* (win->cols+1) + i] = ' ';
- break;
- case 'p':
- win->reverse_video = TRUE;
- break;
- case 'q':
- win->reverse_video = FALSE;
- break;
- case 'v':
- win->wrap_line = TRUE;
- break;
- case 'w':
- win->wrap_line = FALSE;
- break;
- }
- }
- else
- switch (c) {
- case 7:
- Bconout(2,7);
- break;
- case 8:
- if (win->x_cursor > 0)
- win->x_cursor--;
- break;
- case 0x1b:
- win->esc = 1;
- break;
- case 13:
- win->x_cursor=0;
- linecount--;
- break;
- case 10:
- win->y_cursor++;
- cursor_hop = TRUE;
- break;
- case '\t':
- win->x_cursor += TABSTEP - win->x_cursor % TABSTEP;
- cursor_hop = TRUE;
- break;
- default:
- if (c >= ' ') {
- buff_print_at(win, win->x_cursor, win->y_cursor,c,win->reverse_video);
- win->attr[win->y_cursor * win->cols + win->x_cursor] = win->reverse_video;
-
- if (win->wtext[win->y_cursor* (win->cols+1) + win->x_cursor] == '\0') {
- win->wtext[win->y_cursor* (win->cols+1) + win->x_cursor++] = c;
- win->wtext[win->y_cursor* (win->cols+1) + win->x_cursor] = '\0';
- }
- else {
- win->wtext[win->y_cursor* (win->cols+1) + win->x_cursor++] = c;
- }
- }
- break;
- }
-
- if (cursor_hop)
- for (i = 0; (i < win->x_cursor) && (i < win->cols); i++)
- if (win->wtext[win->y_cursor* (win->cols+1) + i] == '\0') {
- win->wtext[win->y_cursor* (win->cols+1) + i] = ' ';
- win->attr[win->y_cursor* win->cols + i] =
- (c == '\t') ? win->reverse_video : FALSE;
- win->wtext[win->y_cursor* (win->cols+1) + i+1] = '\0';
- }
-
- if (win->x_cursor >= win->cols)
- if (win->wrap_line) {
- win->x_cursor = 0;
- win->y_cursor++;
- } else
- win->x_cursor = win->cols;
-
- if (win->y_cursor >= win->lines) {
- if (win->history != 0)
- put_in_hist(win, &win->wtext[0]);
-
- for (i=1; i < win->lines; i++) {
- strcpy(&win->wtext[(i-1)*(win->cols+1)], &win->wtext[i*(win->cols+1)]);
- bcopy(&win->attr[i*win->cols], &win->attr[(i-1)*win->cols], win->cols);
- }
-
- win->y_cursor = win->lines - 1;
- win->wtext[(win->lines-1) * (win->cols+1)] = '\0';
-
- scroll_screen(win, 1);
- }
- }
-
- flush_buff(win);
- if (win->history != 0)
- update_slider(win);
- cursor(win, TRUE);
-
- if (win->status == OPEN) {
- wind_update(FALSE);
- graf_mouse(M_ON,0x0L);
- }
-
- #ifdef DEBUG
- fprintf(stderr, "update_txt_window ends\n");
- #endif
- }
-
- redraw_txt_win(win, rect)
- txt_win *win;
- GRECT *rect;
- {
- int ret;
-
- #ifdef DEBUG
- fprintf(stderr, "redraw_txt_window starts\n");
- #endif
-
- vst_font(handle, win->font);
- vst_point(handle, win->height, &ret,&ret,&ret,&ret);
-
- graf_mouse(M_OFF,0x0L);
-
- redraw_screen(win, rect);
-
- graf_mouse(M_ON,0x0L);
-
- #ifdef DEBUG
- fprintf(stderr, "redraw_txt_window ends\n");
- #endif
- }
-
- open_txt_win(win)
- txt_win *win;
- {
- int tmpx, tmpy, tmpw, tmph;
-
- #ifdef DEBUG
- fprintf(stderr, "open_txt_window starts\n");
- #endif
-
- win->handle=wind_create(WI_KIND,tmpx,tmpy,tmpw,tmph);
- if (win->handle <= 0) {
- form_alert(1,"[0][No more windows ][Hmm]");
- win->status = UNSHOWN;
- return;
- }
-
- wind_set(win->handle, WF_NAME,win->window_name,0,0,0);
- #ifdef DEBUG
- fprintf(stderr, "window name set\n");
- #endif
-
- win->vs_s = 0;
- win->vs_p = 0;
- win->hs_s = 0;
- win->hs_p = 0;
-
- wind_calc(0, WI_KIND, win->xwork, win->ywork, win->wwork, win->hwork,
- &tmpx, &tmpy, &tmpw, &tmph);
- if (win->status != TO_BE_REOPEND)
- graf_growbox(tmpx+tmpw/2,tmpy+tmph/2,gl_wbox,gl_hbox,tmpx,tmpy,tmpw,tmph);
- wind_open(win->handle,tmpx,tmpy,tmpw,tmph);
- #ifdef DEBUG
- fprintf(stderr, "window opend\n");
- #endif
-
- win->status = OPEN;
- update_slider(win);
-
- #ifdef DEBUG
- fprintf(stderr, "open_txt_win ends\n");
- #endif
- }
-
- close_txt_win(win)
- txt_win *win;
- {
- int tmpx, tmpy, tmpw, tmph;
-
- #ifdef DEBUG
- fprintf(stderr, "close_txt_win starts\n");
- #endif
-
- wind_calc(0, WI_KIND, win->xwork, win->ywork, win->wwork, win->hwork,
- &tmpx, &tmpy, &tmpw, &tmph);
- wind_close(win->handle);
- graf_shrinkbox(tmpx+tmpw/2,tmpy+tmph/2,gl_wbox,gl_hbox,tmpx,tmpy,tmpw,tmph);
- wind_delete(win->handle);
- win->status = UNSHOWN;
-
- #ifdef DEBUG
- fprintf(stderr, "close_txt_win ends\n");
- #endif
- }
-
- destroy_txt_win(win)
- txt_win *win;
- {
- #ifdef DEBUG
- fprintf(stderr, "destroy_txt_win starts\n");
- #endif
-
- close_txt_win(win);
- free(win->wtext);
- free(win->attr);
- if (win->history != 0)
- free(win->history);
- win->status = CLOSED;
-
- #ifdef DEBUG
- fprintf(stderr, "destroy_txt_win ends\n");
- #endif
- }
-
- size_txt_win(win, x, y, w, h)
- txt_win *win;
- int x, y, w, h;
- {
- short smaller = FALSE;
-
- #ifdef DEBUG
- fprintf(stderr, "size_txt_win starts\n");
- #endif
-
- if(w < MIN_WIDTH)
- w = MIN_WIDTH;
- if(h < MIN_HEIGHT)
- h = MIN_HEIGHT;
-
- if ((w < win->wwork) || (h < win->hwork))
- smaller = TRUE;
-
- wind_calc(WC_WORK,WI_KIND,x,y,w,h,
- &win->xwork,&win->ywork,&win->wwork,&win->hwork);
- if ((win->cols * win->c_width) < win->wwork)
- win->wwork = win->cols * win->c_width;
- if ((win->lines * win->c_height) < win->hwork)
- win->hwork = win->lines * win->c_height;
-
- win->hwork = (win->hwork / win->c_height) * win->c_height;
- win->wwork = (win->wwork / win->c_width) * win->c_width;
-
- if ((win->x_start + win->wwork/win->c_width) > win->cols)
- win->x_start = win->cols - win->wwork/win->c_width;
- if (win->y_start + 1 + win->lines_written < win->hwork/win->c_height)
- win->y_start = (win->hwork/win->c_height) - win->lines_written - 1 ;
-
- wind_calc(0, WI_KIND, win->xwork, win->ywork, win->wwork, win->hwork,
- &x, &y, &w, &h);
- wind_set(win->handle,WF_CURRXYWH,x,y,w,h);
- win->fulled = FALSE;
-
- update_slider(win);
- if (smaller)
- do_wm_redraw(win);
-
- #ifdef DEBUG
- fprintf(stderr, "size_txt_win ends\n");
- #endif
- }
-
- full_txt_win(win)
- txt_win *win;
- {
- int tmpx, tmpy, tmpw, tmph;
-
- #ifdef DEBUG
- fprintf(stderr, "full_txt_win starts\n");
- #endif
-
- if(win->fulled){
- wind_calc(WC_WORK,WI_KIND,win->xold,win->yold,win->wold,win->hold,
- &win->xwork,&win->ywork,&win->wwork,&win->hwork);
- wind_set(win->handle,WF_CURRXYWH,win->xold,win->yold,win->wold,win->hold);
- }
- else{
- wind_calc(WC_BORDER,WI_KIND,win->xwork,win->ywork,win->wwork,win->hwork,
- &win->xold,&win->yold,&win->wold,&win->hold);
-
- win->wwork = win->cols * win->c_width;
- win->hwork = win->lines * win->c_height;
- wind_calc(0, WI_KIND, win->xwork, win->ywork, win->wwork, win->hwork,
- &tmpx, &tmpy, &tmpw, &tmph);
- wind_set(win->handle,WF_CURRXYWH,tmpx,tmpy,tmpw,tmph);
- }
- win->fulled ^= TRUE;
-
- win->x_start = 0;
- win->y_start = win->lines - 1;
- do_wm_redraw(win);
- update_slider(win);
-
- #ifdef DEBUG
- fprintf(stderr, "full_txt_win ends\n");
- #endif
- }
-
- top_txt_win(win)
- txt_win *win;
- {
- #ifdef DEBUG
- fprintf(stderr, "top_txt_win starts\n");
- #endif
-
- wind_set(win->handle,WF_TOP,0,0,0,0);
-
- #ifdef DEBUG
- fprintf(stderr, "top_txt_win ends\n");
- #endif
- }
-
- arrow_txt_win(win, arrow)
- txt_win *win;
- int arrow;
- {
- GRECT win_rect;
-
- #ifdef DEBUG
- fprintf(stderr, "arrow_txt_win starts\n");
- #endif
-
- switch (arrow) {
- case WA_UPPAGE:
- win->y_start -= win->hwork/win->c_height;
- break;
- case WA_DNPAGE:
- win->y_start += win->hwork/win->c_height;
- break;
- case WA_UPLINE:
- win->y_start--;
- break;
- case WA_DNLINE:
- win->y_start++;
- break;
- case WA_LFPAGE:
- win->x_start -= win->wwork/win->c_width;
- break;
- case WA_RTPAGE:
- win->x_start += win->wwork/win->c_width;
- break;
- case WA_LFLINE:
- win->x_start--;
- break;
- case WA_RTLINE:
- win->x_start++;
- break;
- default:
- break;
- }
-
- if (win->y_start >= win->lines)
- win->y_start = win->lines-1;
- if (- win->y_start > win->lines_written + 1 - (win->hwork/win->c_height))
- win->y_start = (win->hwork/win->c_height) - win->lines_written - 1 ;
-
- if (win->x_start < 0)
- win->x_start = 0;
- if ((win->x_start + win->wwork/win->c_width) > win->cols)
- win->x_start = win->cols - win->wwork/win->c_width;
-
- update_slider(win);
- /* do_wm_redraw(win); */
-
- win_rect.g_x = win->xwork;
- win_rect.g_y = win->ywork;
- win_rect.g_w = win->wwork;
- win_rect.g_h = win->hwork;
- redraw_txt_win(win, &win_rect);
-
- #ifdef DEBUG
- fprintf(stderr, "arrow_txt_win ends\n");
- #endif
- }
-
- hslid_txt_win(win, pos)
- txt_win *win;
- int pos;
- {
- #ifdef DEBUG
- fprintf(stderr, "hslid_txt_win starts\n");
- #endif
-
- win->x_start = pos * (win->cols-win->wwork/win->c_width) / 1000;
-
- update_slider(win);
- do_wm_redraw(win);
-
- #ifdef DEBUG
- fprintf(stderr, "hslid_txt_win ends\n");
- #endif
- }
-
- vslid_txt_win(win, pos)
- txt_win *win;
- int pos;
- {
- #ifdef DEBUG
- fprintf(stderr, "vslid_txt_win starts\n");
- #endif
-
- win->y_start = pos*(win->lines_written + win->lines - win->hwork/win->c_height) /
- 1000 - win->lines_written + win->hwork/win->c_height - 1;
-
- update_slider(win);
- do_wm_redraw(win);
-
- #ifdef DEBUG
- fprintf(stderr, "vslid_txt_win ends\n");
- #endif
- }
-
- mouse_txt_win(win, x, y, n)
- txt_win *win;
- short x, y, n;
- {
- GRECT mouse_rect, win_rect;
- int rw, rh, tx1, ty1, tx2, ty2;
-
- #ifdef DEBUG
- fprintf(stderr, "mouse_txt_win starts\n");
- #endif
-
- if (win->status != OPEN)
- return;
-
- win_rect.g_x = win->xwork;
- win_rect.g_y = win->ywork;
- win_rect.g_w = win->wwork;
- win_rect.g_h = win->hwork;
-
- mouse_rect.g_x = x;
- mouse_rect.g_y = y;
- mouse_rect.g_w = 1;
- mouse_rect.g_h = 1;
-
- if (rc_intersect(&win_rect, &mouse_rect)) {
- mouse_rect.g_x = x;
- mouse_rect.g_y = y;
- graf_rubberbox(x, y, win->xwork-x-1, win->ywork-y-1,
- &mouse_rect.g_w, &mouse_rect.g_h);
- rc_intersect(&win_rect, &mouse_rect);
-
- screen2txt(win, x, y, &tx1, &ty1);
- screen2txt(win, x+mouse_rect.g_w, y+mouse_rect.g_h, &tx2, &ty2);
- copy_to_scrapbuf(win, tx1, ty1, tx2, ty2);
- }
-
- #ifdef DEBUG
- fprintf(stderr, "mouse_txt_win ends\n");
- #endif
- }
-
- write_txt_win(win, fd)
- txt_win *win;
- int fd;
- {
- #ifdef DEBUG
- fprintf(stderr, "write_txt_win starts\n");
- #endif
-
- Fwrite(fd, sizeof(txt_win), (char *)win);
-
- #ifdef DEBUG
- fprintf(stderr, "write_txt_win ends\n");
- #endif
- }
-
- read_txt_win(win, fd)
- txt_win *win;
- int fd;
- {
- int i;
- txt_win buffer;
- struct winsize wsize;
-
- #ifdef DEBUG
- fprintf(stderr, "read_txt_win starts\n");
- #endif
-
- if(Fread(fd, sizeof(txt_win), (char *)&buffer) <= 0)
- return;
-
- win->lines = buffer.lines;
- win->cols = buffer.cols;
- win->wtext = (char *)malloc(win->lines * (win->cols+1));
- if (win->wtext == 0) {
- form_alert(1, mem_txt);
- return;
- }
- win->attr = (char *)malloc(win->lines * win->cols);
- if (win->attr == 0) {
- free(win->wtext);
- win->wtext = 0;
- form_alert(1, mem_txt);
- return;
- }
- for (i = 0; i < win->lines; i++)
- win->wtext[i * (win->cols+1)] = '\0';
-
- win->font = buffer.font;
- win->height = buffer.height;
- vst_font(handle, win->font);
- vst_point(handle, win->height, &ret,&ret,&win->c_width,&win->c_height);
-
- win->xwork = buffer.xwork;
- win->ywork = buffer.ywork;
- win->wwork = buffer.wwork;
- win->hwork = buffer.hwork;
-
- win->hs_s = 0;
- win->hs_p = 0;
- win->vs_s = 0;
- win->vs_p = 0;
-
- win->x_start = 0;
- win->y_start = win->lines - 1;
- win->x_cursor = 0;
- win->y_cursor = 0;
- win->esc = 0;
- win->wrap_line = buffer.wrap_line;
- win->reverse_video = FALSE;
- win->cursor_enabled = TRUE;
- win->x_save = 0;
- win->y_save = 0;
- win->persistent = buffer.persistent;
-
- win->hist_size = buffer.hist_size;
- win->hist_in = 0;
- win->history = (char *)malloc(win->hist_size);
- win->hist_out = win->hist_size-1;
- win->history[win->hist_out] = '\0';
- win->lines_written = 0;
- win->last_out = win->hist_size + 1;
-
- win->status = UNSHOWN;
- win->fulled = FALSE;
-
- win->backslash_conv = buffer.backslash_conv;
- win->keep_on_exit = buffer.keep_on_exit;
-
- strcpy(win->window_name, buffer.window_name);
- strcpy(win->my_args, buffer.my_args);
-
- strcpy(win->cwdir, buffer.cwdir);
-
- wsize.ws_row = win->lines;
- wsize.ws_col = win->cols;
- wsize.ws_xpixel = win->cols * win->c_width;
- wsize.ws_ypixel = win->lines * win->c_height;
- Fcntl(win->real_pty, &wsize, TIOCSWINSZ);
-
- win->real_pty = win->my_pty;
- if (buffer.real_pty != buffer.my_pty) { /* so it must have been tty ! */
- if (!tty_used) {
- win->real_pty = tty;
- tty_used = TRUE;
- }
- else
- return;
- }
-
- open_txt_win(win);
- if (win->status != OPEN) {
- win->status = CLOSED;
- return;
- }
-
- do_av_accwindopen(win->handle);
-
- if (win->real_pty == tty)
- return;
-
- {
- int f0, f1, f2, fm1, client_pty;
- int savedrive;
- char savedir[PATHLEN];
-
- client_pty = Fopen(win->my_pty_name, 2);
- if (client_pty < 0) {
- form_alert(1,"[0][Can not open client pty ][Hmm]");
- }
- else {
- f0 = Fdup(0);
- Fforce(0, client_pty);
- f1 = Fdup(1);
- Fforce(1, client_pty);
- f2 = Fdup(2);
- Fforce(2, client_pty);
- fm1 = Fdup(-1);
- Fforce(-1, client_pty);
- Fclose(client_pty);
-
- savedrive = Dgetdrv();
- Dgetpath(savedir, savedrive+1);
- Dsetdrv(win->cwdir[0] - 'A');
- Dsetpath(&win->cwdir[2]);
-
- if ((win->pid = Pexec(100, buffer.window_name, buffer.my_args,
- _base->p_env)) < 0) {
- win->pid = NO_PID;
- form_alert(1,"[0][Can not execute program ][Hmm]");
- } else {
- Fcntl(win->real_pty, &win->pid, TIOCSPGRP);
- Psetpgrp(win->pid, win->pid);
- Prenice(win->pid, -10);
- }
-
- Dsetdrv(savedrive);
- Dsetpath(savedir);
-
- Fforce(0, f0);
- Fclose(f0);
- Fforce(1, f1);
- Fclose(f1);
- Fforce(2, f2);
- Fclose(f2);
- Fforce(-1, fm1);
- Fclose(fm1);
- }
- }
-
- #ifdef DEBUG
- fprintf(stderr, "read_txt_win ends\n");
- #endif
- }
-